﻿using SFML.Graphics;
using Transformable_Engine_v2.Engine.Transformable_Math.Geometry;

namespace Transformable_Engine_v2.Engine.Graphics
{
    /// <summary>
    /// Class used to describe a Sprite, a sub image in a texture atlas
    /// </summary>
    public class Sprite
    {
        private TE_Rectangle _spriteArea;
        /// <summary>
        /// Sub rectangle where to find the sprite (gridbound)
        /// </summary>
        public TE_Rectangle SpriteArea
        {
            get { return _spriteArea; }
            private set { _spriteArea = value.ToGridBound(); }
        }

        /// <summary>
        /// Pointer to the texture used
        /// </summary>
        public Texture Texture { get; private set; }

        /// <summary>
        /// Creates a new instance of the sprite class
        /// </summary>
        /// <param name="spriteArea">Rectangle where to find the sprite</param>
        public Sprite(TE_Rectangle spriteArea, Texture texture)
        {
            SpriteArea = spriteArea;
            Texture = texture;
        }
        public Sprite(float x, float y, float width, float height, Texture texture)
            : this(new TE_Rectangle(x, y, width, height), texture)
        {
        }
    }
}